package com.example.appframework.login.register.complete;

import androidx.lifecycle.ViewModelProviders;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.appframework.R;
import com.example.appframework.login.LoginMainActivity;

public class CompleteFragment extends Fragment {

    private CompleteViewModel mViewModel;

    public static CompleteFragment newInstance() {
        return new CompleteFragment();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.r_complete_fragment, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mViewModel = ViewModelProviders.of(this).get(CompleteViewModel.class);
        // TODO: Use the ViewModel

        setMyType(getActivity(), 2);

        getView().findViewById(R.id.buttonRegisterCompleted).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NavController navController = Navigation.findNavController(getActivity(),R.id.fragmentLogin);
                navController.navigate(R.id.action_completeFragment_to_loginMethodFragment);
            }
        });
    }

    private void setMyType(Activity activity, int t) {
        super.onAttach(activity);
        ((LoginMainActivity) activity).setType(t);
    }

}